package com.zhengtoudai.ui.presenter;

import android.content.Context;
import android.util.Log;

import com.zhengtoudai.base.LowBasePresenter;
import com.zhengtoudai.ui.bean.ShareRecordModel;
import com.zhengtoudai.http.HttpApi;
import com.zhengtoudai.http.callback.ApiCallback;
import com.zhengtoudai.http.callback.SubscriberCallBack;
import com.zhengtoudai.ui.view.ShareRecordView;

/**
 * 作者：黑哥 on 2016/8/26 17:16
 */
public class ShareRecordPresenter extends LowBasePresenter<ShareRecordView> {

    public ShareRecordPresenter(ShareRecordView view) {
        attachView(view);
    }

    public void loadData(Context context,String umPerPage, String pageNum) {
        Log.e("LW","传的数据=="+umPerPage+"--pageNum="+pageNum);
        mvpView.showLoading();
        addSubscription(HttpApi.getInstance().getShareRecord(umPerPage,pageNum),new SubscriberCallBack<>(context,new ApiCallback<ShareRecordModel>() {
            @Override
            public void onSuccess(ShareRecordModel model) {
                mvpView.getDataSuccess(model);
            }

            @Override
            public void onFailure(int code, String msg) {

                mvpView.getDataFail(code);
            }

            @Override
            public void onCompleted() {
                mvpView.hideLoading();
            }

            @Override
            public void onError(Throwable e) {

            }
        }));
    }
}
